package com.huamao.niceman.scrollviewpager.home;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.TextView;

import com.huamao.niceman.scrollviewpager.R;
import com.huamao.niceman.scrollviewpager.base.BaseActivity;
import com.huamao.niceman.scrollviewpager.classify.view.ClassifyFragment;
import com.huamao.niceman.scrollviewpager.home.view.HomeFragment;
import com.huamao.niceman.scrollviewpager.information.view.InformationFragment;
import com.huamao.niceman.scrollviewpager.mine.view.MineFragment;
import com.huamao.niceman.scrollviewpager.widget.TabView;
import com.huamao.niceman.scrollviewpager.widget.TabViewChild;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by LuanXianSheng on 2017/6/12.
 */

public class HomeActivity extends BaseActivity {


    @BindView(R.id.tabview)
    TabView tabview;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);
        ButterKnife.bind(this);
        setAct(this);
        initView();
        initData();
        initViewOper();
    }

    @Override
    public void initView() {

    }

    @Override
    public void initData() {
        tabview = (TabView) findViewById(R.id.tabview) ;
        List<TabViewChild> date = new ArrayList<>() ;
        TabViewChild tabViewChild01=new TabViewChild(R.drawable.tab01_sel,R.drawable.tab01_unsel,"首页",  new HomeFragment());
        TabViewChild tabViewChild02=new TabViewChild(R.drawable.tab02_sel,R.drawable.tab02_unsel,"分类", new ClassifyFragment());
        TabViewChild tabViewChild03=new TabViewChild(R.drawable.tab03_sel,R.drawable.tab03_unsel,"资讯", new InformationFragment());
        TabViewChild tabViewChild04=new TabViewChild(R.drawable.tab05_sel,R.drawable.tab05_unsel,"我的", new MineFragment());
        date.add(tabViewChild01);
        date.add(tabViewChild02);
        date.add(tabViewChild03);
        date.add(tabViewChild04);
        tabview.setTabViewDefaultPosition(0);
        tabview.setTabViewChild(date,getSupportFragmentManager());
        tabview.setOnTabChildClickListener(new TabView.OnTabChildClickListener() {
            @Override
            public void onTabChildClick(int  position, ImageView currentImageIcon, TextView currentTextView) {
//                 Toast.makeText(getApplicationContext(),"position:"+position, Toast.LENGTH_SHORT).show();
            }
        });
    }

    @Override
    public void initViewOper() {

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        setAct(null);
    }
}
